<div class="modal-dialog" id="selectUrl" style="width: 930px;">

    <div class="modal-content">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h4 class="modal-title">选择链接</h4>
        </div>
        <div class="modal-body">
            <ul class="nav nav-tabs" id="selectUrlTab">
                {if condition="$linkstype == 'all'"}
                <li class="active"><a href="#sut_shop" data-toggle="tab">商城</a></li>
                {/if}
                {if condition="$linkstype == 'all' || $linkstype == 'article'"}
                <li class="{$linkstype=='article'?'active':''}"><a href="#sut_article" data-toggle="tab">文章</a></li>
                {/if}
                {if condition="$linkstype == 'all' || $linkstype == 'goods'"}
                <li class=""><a href="#sut_good" data-toggle="tab">商品</a></li>
                {/if}
                {if condition="$linkstype == 'all'"}
                    <li class=""><a href="#sut_cate" data-toggle="tab">商品分类</a></li>

                    <li class="hide"><a href="#sut_coupon" data-toggle="tab">超级券</a></li>
                    <li><a href="#sut_diypage" data-toggle="tab">装修</a></li>
                    {notempty name="$is_activity"}
                    <li><a href="#sut_activity" data-toggle="tab">活动</a></li>
                    {/notempty}
                {/if}

            </ul>
            <div class="tab-content ">

                <div class="tab-pane {$linkstype=='all'?'active':''}" id="sut_shop">
                    <div class="page-head"><h4><i class="fa fa-folder-open-o"></i> 商城页面</h4></div>
                    {volist name="links" id="vo" }
                    <nav  data-id="0"  data-href="{$vo.url}" class="btn btn-default btn-sm" title="{$vo.name}">{$vo.name}</nav>
                    {/volist}
                </div>

                <div class="tab-pane {$linkstype=='goods'?'active':''}" id="sut_good">
                    <div class="input-group">
                        <input type="text" placeholder="请输入商品名称进行搜索" id="select-good-kw" value="" class="form-control">
                        <span class="input-group-addon btn btn-default select-btn" data-type="good">搜索</span>
                    </div>
                    <div id="select-good-list"></div>
                </div>

                <div class="tab-pane" id="sut_cate">
                    {volist name="CategoryList" id="vo" }
                    <div class="line">
                        <div class="icon icon-{$vo.level}"></div>
                        <nav title="选择" class="btn btn-default btn-sm" data-id="0" data-href="/pages/shop/goods/index?cateId={$vo['id']}">
                            选择
                        </nav>
                        <div class="text">{$vo.name}</div>
                    </div>
                    {/volist}
                </div>

                <div class="tab-pane {$linkstype=='article'?'active':''}" id="sut_article">
                    <div class="input-group">
                        <input type="text" placeholder="请输入文章名称进行搜索" id="select-article-kw" value=""
                               class="form-control">
                        <span class="input-group-addon btn btn-default select-btn" data-type="article">搜索</span>
                    </div>
                    <div id="select-article-list"></div>
                </div>

                <div class="tab-pane" id="sut_coupon">
                    <div class="input-group">
                        <input type="text" placeholder="请输入优惠券名称进行搜索" id="select-coupon-kw" value=""
                               class="form-control">
                        <span class="input-group-addon btn btn-default select-btn" data-type="coupon">搜索</span>
                    </div>
                    <div id="select-coupon-list"></div>
                </div>
                <div class="tab-pane" id="sut_diypage">
                    <div class="input-group">
                        <input type="text" placeholder="请输入装修名称进行搜索" id="select-diypage-kw" value=""
                               class="form-control">
                        <span class="input-group-addon btn btn-default select-btn" data-type="diypage">搜索</span>
                    </div>
                    <div id="select-diypage-list"></div>
                </div>
                <div class="tab-pane" id="sut_activity">
                    {empty name="ActivityList"}
                    <div class="tip">暂无相关活动信息。</div>
                    {else/}
                    {volist name="ActivityList" id="vo" }
                    <div class="line good">
                        <div class="image"><img src="{$vo.activity_img}"/></div>
                        <nav title="选择" class="btn btn-default btn-sm" data-id="0" data-href="/activity/index/index/id/{$vo.id}">
                            选择
                        </nav>
                        <div class="text">
                            <p class="name">{$vo.activity_title}</p>
                        </div>
                    </div>
                    {/volist}
                    {/empty}
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
        </div>

    </div>

</div>
<script type="text/javascript">
    $(function(){
        $(document).off("click",".select-btn");
        $(document).on("click",".select-btn",function(){
            var type = $(this).data("type");
            var kw = $.trim($("#select-"+type+"-kw").val());
            if(!kw){
                _alert("请输入搜索关键字！",true);
                return;
            }
            $("#select-"+type+"-list").html('<div class="tip">正在进行搜索...</div>');
            $.ajax("{:url('search')}", {
                type: "get",
                dataType: "html",
                cache: false,
                data: {kw:kw, type:type}
            }).done(function (html) {
                $("#select-"+type+"-list").html(html);
            });
        });
    });
    $(document).off('click','nav');
    $(document).on('click','nav',function(){
        console.log(000);
        var url = $(this).data('href');
        var id = $(this).data('id');
        var title = $(this).data('title');
        {if condition="$linksfun == 'assigBack'"}
            return assigBack('{$searchType}','{$_menu_index}',id,title,url);
        {/if}
        {if condition="$linksfun == 'editorBack'"}
            $(".modal-dialog .close").trigger("click");
            return UE.getEditor(edui_editor_id).execCommand('link', {href: url, 'data-nocache': 'true'});
        {/if}
        window.parent.McMore.selectUrlCallback(url,'{$searchType}','{$_menu_index}');
    })
</script>
